;(function() {
	Nokia.PicasaItemView = Nokia.View.extend({
		
		/*
		 * Initializes Guarana components
		 */
		init: function()
		{
			var instance = this;
			
			this.contentElement = this.getContainer().find('#picasa-item-content');
			
			this.itemOpenButton = new Nokia.Button({
				element: '#picasa-item-open-button',
				label: 'Original Image',
				width: '50%',
				click: function() {
					instance.openInWebBrowser();
				}
			});
		},
		
		/*
		 * Opens the Picasa Web link
		 */
		openInWebBrowser: function()
		{
			widget.openURL(this.item.web_url);
		},
		
		/*
		 * Shows a Picasa result item
		 */
		showItem: function(item)
		{
			this.item = item;

			var itemHTML = Nokia.GBCServices.getServiceItemSnippet(item);
			
			itemHTML += '<img onload="Nokia.GBCUtils.normalizeImageWidth(event)" class="clearer item-detail-photo" src="' + item.url + '" />';
				
			this.contentElement.html(itemHTML);	
		},
		
		/*
		 * Called when this view needs to be shown
		 */
		show: function(item)
		{
			// Replace the Exit button with a Back button
			
			var template = this.getTemplate();
			
			var topBar = template.getHeaderTopBar();
			var viewManager = template.getViewManager();
			
			var defaultTopItems = GBC.getDefaultTopItems();
			
			defaultTopItems[0] = {classname: 'nokia-template-header-icon-back', callback: function() { viewManager.back() }};
			
			topBar.setItems(defaultTopItems);
			
			this.showItem(item);
			
			this.getContainer().show();
		}
	});
})();